#ifndef INC_METABALL_H_
#define INC_METABALL_H_

#include "raytracer.h"
#include "sphere.h"
#include "Polinomio.h"
#include <vector>
#include <list>

typedef struct Intersection{
	double t;
	bool in;
	int metaballId;
	Intersection(double at, bool ain, int ametaballId): t(at), in(ain), metaballId(ametaballId){}
	}Intersection;

typedef std::vector<Intersection> Intersections;


class Metaball : public CRTObject {
public:
	std::vector<VECTOR> centers;
	std::vector<SCALAR> radius;
	std::vector<Polinomio> fieldsPolynoms;
	std::vector<bool> usedPolys;
	SCALAR tHit;
	double m_thershold;

  Metaball (std::vector<VECTOR> acenters, std::vector<SCALAR> aradius, double am_thershold);
  Intersections Metaball::getMetaballsIntersections(const CLine & line);
  void getPolysFieldDenisty(const CLine & line, int metaballID);
  bool hits (const CLine &line, SCALAR &t_hit);
  VECTOR getNormal(const VECTOR &hit_loc);
};

#endif
